#include "AccessGenerater.h"
#include <stdlib.h>
AccessGenerater::AccessGenerater( int id, int ad, int ar )
{
	m_id = id;
	cur_interval = 0;
	
	if(ad == 1)
		m_interval = 1;
	else
		m_interval = const_interval;

	if(ar==3)
		m_range = 1000;
	else
		m_range = const_range;

	if(ad==2 && ar==4)
		is_Priority = true;
}


AccessGenerater::~AccessGenerater(void)
{
}

int AccessGenerater::getAccess()
{
	cur_interval++;
	if(cur_interval >= m_interval){
		cur_interval = 0;
		return computeAccess();
	}
	else
		return -1;
}

int AccessGenerater::computeAccess()
{

	int block_address = rand()%m_range;
	return m_id*1000+ block_address;
}
